package com.neusoft.zqygbc.neusoft_wenda.adapter;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.neusoft.zqygbc.neusoft_wenda.R;
import com.neusoft.zqygbc.neusoft_wenda.activity.QuestionContentActivity;
import com.neusoft.zqygbc.neusoft_wenda.base.RecyclerViewAdapter;
import com.neusoft.zqygbc.neusoft_wenda.javeBean.AnswersEntity;

import java.util.List;

public class CreateAnswerAdapter extends RecyclerViewAdapter<com.neusoft.zqygbc.neusoft_wenda.adapter.CreateAnswerAdapter.ViewHolder> {


    public CreateAnswerAdapter(Context context, List data, int layoutResource) {
        super(context, data, layoutResource);
    }

    @Override
    public void onBindViewHolder(final com.neusoft.zqygbc.neusoft_wenda.adapter.CreateAnswerAdapter.ViewHolder holder, final int position) {
        final AnswersEntity entity = (AnswersEntity) data.get(position);
        holder.myanswer_date.setText(entity.getAnswerstime());
        holder.myanswer_content.setText(entity.getAnswerstexrt());
        holder.myanswer_container.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, QuestionContentActivity.class);
                intent.putExtra("qid", entity.getQid());
                intent.putExtra("question_uid", entity.getUid());
                context.startActivity(intent);
            }
        });

    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        TextView myanswer_date,myanswer_content;
        LinearLayout myanswer_container;
        CardView answer_cardView;

        public ViewHolder(View itemView) {
            super(itemView);
            answer_cardView = (CardView) itemView.findViewById(R.id.answer_cardView);
            myanswer_date = (TextView) itemView.findViewById(R.id.myanswer_date);
            myanswer_content = (TextView) itemView.findViewById(R.id.myanswer_content);
            myanswer_container = (LinearLayout) itemView.findViewById(R.id.myanswer_container);

        }
    }






}

